package com.ql.mangersystem.mapper;

import com.ql.mangersystem.entity.po.Orders;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Entity com.ql.mangersystem.entity.po.Orders
 */
@Mapper
public interface OrdersMapper {

    @Insert("insert into `orders` (no,name,date,money,category,userid)values (#{no},#{name},#{date},#{money},#{category},#{userid})")
    int save(@Param("no") String no,@Param("name") String name, @Param("date") String date, @Param("money") BigDecimal money,@Param("category") String category,@Param("userid") Integer userid);

    @Update("update orders set category=#{category},date=#{date},name=#{name},money=#{money} where id =#{id}")
    int update(@Param("category") String category, @Param("date") String date, @Param("name") String name, @Param("money") BigDecimal money,@Param("id")Integer id);

    @Delete("delete from orders where id=#{id}")
    int delete(Integer id);

    int deleteBatch(@Param("ids") List<Integer> ids,@Param("userid") Integer userid);

    @Select("select * from orders where userid=${useid} order by date limit #{skipNum},#{pageSize}")
    List<Orders> page(@Param("skipNum") Integer skipNum, @Param("pageSize") Integer pageSize, @Param("userid") Integer userid);

    @Select("select count(id) from orders where userid=#{userid}")
    Integer count(Integer userid);

    @Select("select *from orders where name like concat('%',#{name},'%') and  userid=#{userid} order by date limit #{skipNum},#{pageSize}")
    List<Orders> pageLike(@Param("skipNum") Integer skipNum,@Param("pageSize") Integer pageSize,@Param("name") String name, @Param("userid") Integer userid);

    @Select("select count(id) from orders where userid=#{userid} and name like concat('%',#{name},'%')")
    Integer countLike(@Param("name") String name, @Param("userid") Integer userid);

    @Select("select * from orders where id=#{id} and userid=#{userid}")
    Orders selectById(@Param("id") Integer id,@Param("userid") Integer userid);

    @Select("select * from orders where userid=#{userid}")
    List<Orders> list(Integer userid);
}




